package 排序;

/**
 * @author Kevin
 * @Data 2021/2/16
 * 选择排序
 */
public class selectSort {
    public static void main(String[] args){
        int [] b ={7,3,5,6,1,11,22,9,4,4,1};
        sort(b);
        for (int i = 0; i < b.length ; i++) {
            System.out.print(b[i]);
            System.out.print(" ");
        }
    }
    public static void sort(int[] L){
        for (int i = 0; i < L.length-1; i++) {
            int min = i;
            for (int j = i; j < L.length; j++) {
                if(L[min] > L[j]){
                    min = j;
                }
            }
            if(i!=min){
                int temp = L[i];
                L[i] = L[min];
                L[min] = temp;
            }
        }
    }
}
